<template>
	<view>
		<gameBasics backgroundColor="rgba(254, 209, 148, .4)" />
		<fireworks />
		<view class=""
			style="display: flex;justify-content: space-between;flex-direction: column;height: calc(100vh - calc(120vmin / 7.5));padding:calc(60vmin / 7.5);">

			<view class="team_information">
				<image :src="confirm_result.team_pic" mode="aspectFill"></image>
				<text>{{confirm_result.team_title||''}}</text>
				<!-- <text>3:22</text> -->
			</view>
			<view class="title">
				恭喜完成挑战  成绩为：{{game_config.type==1||game_config.type==3?$util.timeFormat(confirm_result.number):confirm_result.number+'分'}}
			</view>
<!-- 			<block v-if="gameData.team==1">
				<view class="game_btn">
					<view class="">

					</view>
					查看线索
				</view>
				<view class="" style="display: flex;">
					<view class="game_btn" style="opacity: 0;">
						<view class="">

						</view>
						查看线索
					</view>
					<view class="game_btn">
						<view class="">
							<view class="" v-if="activ_det.name"
								style="position: absolute;top: calc(60vmin / 7.5);right:0;color: #666666;font-size: calc(28vmin / 7.5);">
								（{{activ_det.name}}）
							</view>
						</view>
						<view class="" style="display: flex;position: relative;z-index: 9999;">
							<view  @click="whetherRest(2)">休息一下</view> <view class="line">|</view> <view   @click="whetherRest(1)" :style="{color:activ_det.name?'':'#999'}">继续挑战</view>
						</view>
						
					</view>
					<view class="game_btn">
						<view class="">

						</view>
						再次挑战
					</view>
				</view>

			</block> -->
			<!-- <view v-else class="" style="text-align: center;">
      	
      </view> -->

			<view>
				<text class="time">0{{date}}s</text>
			</view>
		</view>
<gameLoading/>
	</view>
</template>

<script>	
	import fireworks from '@/components/sanshui-fireworks/sanshui-fireworks.vue'
	let num = null
	export default {
		components: {
			fireworks
		},
		data() {
			return {
		   confirm_result:{},
				teamList: [],
				game_config:{},
				date: 11,
				acceptStatus:true
			}
		},

		onUnload() {
			this.acceptStatus=false
		},
		onLoad() {
			if(num){
				clearInterval(num);
				num=null
			} 
			num = setInterval(() => {
				this.date--
				if (this.date <= 0) {		
					clearInterval(num);
					num=null
					uni.redirectTo({
						url: '/pages/gameTemplate/timekeeping/timekeeping'
					})
				}
			}, 1000)
		},

		mounted() {
			
			

			uni.$on('onMessage',(res)=>{
				if(!this.acceptStatus) return;
					this.$nextTick(()=>{
						this.$store.commit('switchGame', {
							code: false
						})
					})
				let confirm_result=res.data.confirm_result
			 this.confirm_result=confirm_result[confirm_result.length-1]
			 this.game_config = res.data.game_config
			 this.teamList = res.data.team
			 this.teamList.forEach(item=>{
				 if(item.id==this.confirm_result.team_id){
					 this.confirm_result.team_title=item.title
					 this.confirm_result.team_pic=item.pic
				 }
			 })

			})
			let game_id = uni.getStorageSync("gameId")
			let userData = uni.getStorageSync("userData")			
			this.$ws.socketTask.send({
				data: JSON.stringify({
				game_id,
				user_id: userData.id
			}),
				async success() {
					console.log("消息发送成功")
				}
			});
			
		

		},
		methods: {
			whetherRest(type){
				this.$myRuquestWs('home/game/game_status',{game_id:this.gameData.id,activ_id:this.gameData.activ_id,type},'POST').then(res=>{
					
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.title {
		color: #FF5A5A;
		font-size: calc(44vmin / 7.5);
		text-align: center;
	}

	.time {
		background-color: rgba(0, 0, 0, .23);
		color: #fff;
		width: calc(170vmin / 7.5);
		height: calc(70vmin / 7.5);
		line-height: calc(70vmin / 7.5);
		border-radius: calc(35vmin / 7.5);
		text-align: center;
		font-size: calc(32vmin / 7.5);
		float: right;
	}
	.team_information{
		image{
			margin-right: calc(20vmin / 7.5);
		}
	}
</style>
